﻿@model SklepISI.Web.Models.Admin.OrderDetailViewModel

@{
    ViewBag.Title = "OrderDetails";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script>
    $(function () {
        $(".updateOrderStatus").on("click", function() {
            $.post('@Url.Action("ChangeOrderStatus")',
                {
                    orderId: $("#Order_Id").val(),
                    statusId: $("#Order_Status_ID").val()
                }, function(json) {
                    if (json == "OK") {
                        $(".savedSuccess").remove();
                        $(".statusDD").prepend("<div class='alert alert-success savedSuccess'>Zapisano..</div>");
                    }
                });
        });
    })
</script>
<h3>Detale zamówienia</h3>
@Html.HiddenFor(m=>m.Order.Id)
<p>ID: @Model.Order.Id</p>
<p>User: @Model.Order.User.Username</p>
<p>Adres dostawy: @Model.Order.DeliveryAddress</p>
<p class="statusDD">Status: @Html.DropDownListFor(m => m.Order.Status.ID, new SelectList(Model.OrderStatuses, "ID", "Name"), new { @style="height: 30px;"}) <a style="margin-bottom: 12px;" class="btn btn-small btn-success updateOrderStatus"><i class="icon-white icon-ok"></i> Zapisz</a></p>
<p>
    <table class="table table-striped">
        <thead>
            <tr>
                <th>Nazwa</th>
                <th>Cena jednostkowa</th>
                <th>Ilość</th>
                <th>Cena</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var prod in Model.Order.Products)
            {
                <tr productId="@prod.Product.ProductId">
                    <td>@prod.Product.Name</td>
                    <td>@String.Format("{0:C}", prod.Product.Price)</td>
                    <td class="quantity">@prod.Quantity</td>
                    <td class="totalProductPrice">@String.Format("{0:C}", prod.Product.Price * prod.Quantity)</td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr>
                <td colspan="4" style="text-align: right; font-weight: bold;">Suma: <span id="totalCartPrice">@String.Format("{0:C}", Model.TotalAmount)</span></td>
            </tr>
        </tfoot>
    </table>
</p>
